<template>
	<div class="game-self">
		<div v-if='this.$route.query.gameName.includes("股林大会")'>
		  <self-header :title='this.$route.query.gameName' :hasShare='true' :showRefresh='true' v-on:refresh='refresh'  v-on:onShare='onshare'></self-header>
	      <gulin-base-info :pageStatus='page'></gulin-base-info>
	      <gulin-current-position></gulin-current-position>
	      <gulin-selfdetail-footer></gulin-selfdetail-footer>
		</div>
		<div v-else>
		  <header-top :option="headerOption"></header-top>
	      <base-info :pageStatus='page'></base-info>
	      <current-position></current-position>
	      <selfdetail-footer></selfdetail-footer>
		</div>
	</div>

</template>

<script>
	import HeaderTop from 'components/HeaderTop'
	import SelfHeader from 'components/game/selfdetail/selfHeader'
	import BaseInfo from 'components/game/selfdetail/BaseInfo'
	import gulinBaseInfo from 'components/game/selfdetail/gulinBaseInfo'
	import CurrentPosition from 'components/game/selfdetail/CurrentPosition'
	import gulinCurrentPosition from 'components/game/selfdetail/gulinCurrentPosition'
	import SelfDetailFooter from 'components/game/selfdetail/SelfDetailFooter'
	import gulinSelfDetailFooter from 'components/game/selfdetail/gulinSelfDetailFooter'
	import Constant from 'common/constant'
	import { buryPoint } from 'common/decorator'
	import LocalDAO from 'common/localDAO'
	import RemoteDAO from 'common/remoteDAO'

    /**
       * 参数：
       * gameId  比赛id  必传
       * gameName  比赛名称   必传
       *
       * 调用示例：
       * this.$router.push({path: '/game/gameselfdetail', query: {gameId : this.overview.gameId ,gameName : this.overview.gameName ,teamName : this.teamName}})
    */
	export default {
		data() {
			return {
				headerOption: {
					title: this.$route.query.gameName,
					operations: [Constant.operation.REFRESH, Constant.operation.SHARE],
					page: Constant.storage.SHARE_GAME_SELF_DETAIL
				},
				page:'self',
				gameId: this.$route.query.gameId,
				usercode: LocalDAO.getUserCode()
			}
		},
		components: {
			'header-top': HeaderTop,
			'self-header': SelfHeader,
			'base-info': BaseInfo,
			'selfdetail-footer': SelfDetailFooter,
			'current-position': CurrentPosition,
			'gulin-base-info': gulinBaseInfo,
			'gulin-current-position': gulinCurrentPosition,
			'gulin-selfdetail-footer': gulinSelfDetailFooter
		},
		created: function() {
			this.init()
			//          this.$store.dispatch('setLoading',{visible:true});
		},
		methods: {
		  @buryPoint('13009', function() { return { gameid: this.gameId }})
		  // @buryPoint('23101', function() { return { usercode: this.usercode, source: 'teamDetail' }})
          init () {
          	console.log('我的持仓页面初始化')
            let gameSelfDetail = LocalDAO.getShareGameSelfDetails() || {};
            gameSelfDetail.gameName = this.$route.query.gameName || '';
            LocalDAO.setShareGameSelfDetails(gameSelfDetail);
          },
          refresh () {
          	window.location.reload();
          },
          onshare () {
          	const usercode = LocalDAO.getUserCode()
          	const gameSelfDetail = LocalDAO.getShareGameSelfDetails().gameAsset.total_profitrate
          	const title = '我是股林大会中' + this.$route.query.teamName + '的首席弟子'
          	const content = '目前收益率百分之' + Number(gameSelfDetail) + '！一起来股林大会，大展身手吧！'
          	const icon = 'https://dl.app.gtja.com/web/gulindahui/share/gulinshare.jpg'
          	const linkurl = 'http://dl.app.gtja.com/nrng/newShares/gldh-game-award.html?source=selfDetail&usercode=' + usercode + '&content=' + content + '&title=' + title
          	RemoteDAO.share(title, content, linkurl, 'title', icon)
          }
		}
	}
</script>

<style lang="css" scoped>
.game-self {
  background-color: #fff;
}
</style>
